<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * Created by PhpStorm.
 *
 * @Date: 2017-06-07
 * @Time: 11:22
 * @Author: cdkay
 * @Email: network@iyuanma.net
 *
 * @File： Base.php
 */
class MY_Controller extends CI_Controller {
    public function __construct()
    {

        parent::__construct();

        // 登录验证
        if (!$this->admin_auth->check_user_login()) {
            if (IS_AJAX) {
                $result = array('status'=>-1, 'msg'=>'您还未登录', 'result'=>array('jumpUrl'=>site_url('prompt/not_login')));
                exit(json_encode($result));
            } else {
                redirect(site_url('../prompt/not_login'));
            }
        }

        // 权限验证
        if (!$this->admin_auth->check_auth()) {
            if (IS_AJAX) {
                $result = array('status'=>-1, 'msg'=>'您没有权限进行此项操作', 'result'=>'');
                exit(json_encode($result));
            } else {
                redirect(site_url('../prompt/auth'));
            }
        }
    }
}